package cn.tedu.csmall.order.webapi.quartz;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OrderAddConfig {
    @Bean
    public JobDetail orderAdd(){
        return JobBuilder.newJob(OrderAddJob.class)
                .withIdentity("orderAdd")
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger orderAddTrigger(){
        CronScheduleBuilder corn = CronScheduleBuilder.cronSchedule("0 0/2 * 2 2 ?");
        return TriggerBuilder.newTrigger()
                .forJob(orderAdd())
                .withIdentity("orderAddTrigger")
                .withSchedule(corn)
                .build();
    }
}
